package com.hc.javassist;

import com.android.build.gradle.AppExtension;
import com.android.build.gradle.BaseExtension;
import com.android.build.gradle.LibraryExtension;

import org.gradle.api.Plugin;
import org.gradle.api.Project;

public class ClassPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {
        System.out.println("-----init-----");
        BaseExtension baseExtension = project.getExtensions().findByType(AppExtension.class);
        System.out.println("-----finding-----");
        if(baseExtension == null){
            System.out.println("-----finding-----");
            baseExtension = project.getExtensions().findByType(LibraryExtension.class);
        }
        if(baseExtension != null){
            System.out.println("-----register-----");
            baseExtension.registerTransform(new ClassTransform(baseExtension));
        }
    }
}